package com.shunli.cterminal.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.examples.core.mybatis.service.AbstractService;
import com.shunli.cterminal.entity.SystemProject;
import com.shunli.cterminal.mapper.SystemProjectMapper;
import com.shunli.cterminal.service.ProjectService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class ProjectServiceImpl extends AbstractService<SystemProjectMapper, SystemProject> implements ProjectService {

    /**
     * @param codeList 编码
     * @return Map<String, SystemProject>
     */
    @Override
    public Map<String, SystemProject> queryMap(List<String> codeList) {
        if(CollectionUtil.isEmpty(codeList)){
            return new HashMap<>();
        }
        List<SystemProject> systemProjectList = this.baseMapper.queryProjectInfoByCodeList(codeList);
        if(CollectionUtil.isEmpty(systemProjectList)){
            return new HashMap<>();
        }
        return systemProjectList.stream().collect(Collectors.toMap(SystemProject::getCode, Function.identity(), (v1, v2) -> v1));
    }
}
